package com.gitee.wsl.compose.ui.richtext.edit.state

import com.gitee.wsl.compose.ui.richtext.edit.annotation.ExperimentalRichTextApi
import com.gitee.wsl.compose.ui.richtext.edit.model.span.style.Code

/**
 * Returns whether the current selected text is a code span.
 */
@OptIn(ExperimentalRichTextApi::class)
val RichTextState.isCodeSpan: Boolean get() = isRichSpan<Code>()

@OptIn(ExperimentalRichTextApi::class)
fun RichTextState.toggleCodeSpan() = toggleRichSpan(Code())

@OptIn(ExperimentalRichTextApi::class)
fun RichTextState.addCodeSpan() = addRichSpan(Code())

@OptIn(ExperimentalRichTextApi::class)
@Suppress("ImplicitSamInstance")
fun RichTextState.removeCodeSpan() = removeRichSpan(Code())
